#include <iostream>
#include <stdio.h>

class Base
{
	public:
		void function_1()
		{
			printf("function_1...\n");
		}

		virtual void function_2()
		{
			printf("function_2...\n");
		}
};

int main(int argc, char ** argv)
{
	Base base;
	Base *pb;

	pb = &base;

	pb->function_1();
	pb->function_2();
}

#if 0

1.当virtual通过对象去调用时与普通函数没有区别，是直接（E8)调用。
2.当virtual通过指针去调用时生成的调用是个间接（FF）调用。

int main(int argc, char ** argv)
{
    11a9:	f3 0f 1e fa          	endbr64 
    11ad:	55                   	push   %rbp
    11ae:	48 89 e5             	mov    %rsp,%rbp
    11b1:	48 83 ec 30          	sub    $0x30,%rsp
    11b5:	89 7d dc             	mov    %edi,-0x24(%rbp)
    11b8:	48 89 75 d0          	mov    %rsi,-0x30(%rbp)
    11bc:	64 48 8b 04 25 28 00 	mov    %fs:0x28,%rax
    11c3:	00 00 
    11c5:	48 89 45 f8          	mov    %rax,-0x8(%rbp)
    11c9:	31 c0                	xor    %eax,%eax
	Base base;
    11cb:	48 8d 05 ae 2b 00 00 	lea    0x2bae(%rip),%rax        # 3d80 <_ZTV4Base+0x10>
    11d2:	48 89 45 e8          	mov    %rax,-0x18(%rbp)
	Base *pb;

	pb = &base;
    11d6:	48 8d 45 e8          	lea    -0x18(%rbp),%rax
    11da:	48 89 45 f0          	mov    %rax,-0x10(%rbp)

	pb->function_1();
    11de:	48 8b 45 f0          	mov    -0x10(%rbp),%rax
    11e2:	48 89 c7             	mov    %rax,%rdi
    11e5:	e8 94 00 00 00       	callq  127e <_ZN4Base10function_1Ev>
	pb->function_2();
    11ea:	48 8b 45 f0          	mov    -0x10(%rbp),%rax
    11ee:	48 8b 00             	mov    (%rax),%rax
    11f1:	48 8b 10             	mov    (%rax),%rdx
    11f4:	48 8b 45 f0          	mov    -0x10(%rbp),%rax
    11f8:	48 89 c7             	mov    %rax,%rdi
    11fb:	ff d2                	callq  *%rdx
}
    11fd:	b8 00 00 00 00       	mov    $0x0,%eax
    1202:	48 8b 4d f8          	mov    -0x8(%rbp),%rcx
    1206:	64 48 33 0c 25 28 00 	xor    %fs:0x28,%rcx
    120d:	00 00 
    120f:	74 05                	je     1216 <main+0x6d>
    1211:	e8 7a fe ff ff       	callq  1090 <__stack_chk_fail@plt>
    1216:	c9                   	leaveq 
    1217:	c3                   	retq   


#endif
